﻿using System;
using System.Drawing;
using System.Windows.Forms;
using TimedText.Styling;

namespace TimedTextLibrary
{
    public class TimedTextCaption
    {
        public string CaptionText { get; set; }
        public TimeSpan? StartTime { get; set; }
        public TimeSpan? EndTime { get; set; }

        public Color? BackgroundColor { get; set; }
        public Color? FontColor { get; set; }
        public FontSize FontSize { get; set; }

        public FontStyle? FontWeight{ get; set; }
        public FontStyle? FontStyle { get; set; }
        public string TextAlign { get; set; }
        public string TextDecoration { get; set; }

        public bool Equals(TimedTextCaption other)
        {
            if (ReferenceEquals(null, other)) return false;
            if (ReferenceEquals(this, other)) return true;
            return Equals(other.CaptionText, CaptionText) && other.StartTime.Equals(StartTime) && other.EndTime.Equals(EndTime);
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            if (obj.GetType() != typeof (TimedTextCaption)) return false;
            return Equals((TimedTextCaption) obj);
        }

        public override int GetHashCode()
        {
            unchecked
            {
                int result = (CaptionText != null ? CaptionText.GetHashCode() : 0);
                result = (result*397) ^ (StartTime.HasValue ? StartTime.Value.GetHashCode() : 0);
                result = (result*397) ^ (EndTime.HasValue ? EndTime.Value.GetHashCode() : 0);
                return result;
            }
        }
    }
}
